package cn.tedu.spring.life;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;


/**
 * @ProperSource,@Value 可以读取外部的配置文件中的属性
 * 本质上是通过PropertySourcesPlaceholderConfigurer来实现的BFPP
 * 它也重写了postProcessBeanFcatory方法，该方法用于读取这些配置文件内容
 */
@Component
@PropertySource(value = "classpath:person.properties",encoding = "utf-8")
public class Person {

    @Value("${person.name}")
    private String name;


    @Value("${person.age}")
    private Integer age;

    @Override public String toString() {

        return "Person{" +
            "name='" + name + '\'' +
            ", age=" + age +
            '}';
    }
}
